<?php
namespace app\index\controller;

use think\Config;
use app\common\util\Redis;
use think\Controller;

class Index extends Controller
{
    public function index()
    {
        return 'hello yunlutoFDSFng!';
    }
    public function Demo()
    {
    	dump(config('database'));
    }

    /*redis*/
    public function redisa(){
        $redis = new Redis();
        $redis->client->set('yltdemo','ylt'.time());
        $res = $redis->client->get('yltdemo');
        $arr['code'] = 0;
        $arr['msg'] = $res;
        var_dump($arr);
    }
    /*redis锁测试*/
    public function redisb(){
        $redis = new Redis();
        $key = 'balance-1';
        if($redis->getLock($key)){
            sleep(5);
            echo 'yes';
            $redis->removeLock($key);
        }else{
            echo 'no';
        }
    }
    public function redisc(){
        $redis = new Redis();
        $key = 'balance-1';
        if($redis->getLockEnabel($key)){
            echo 'yes';
            $redis->removeLock($key);
        }else{
            echo 'no';
        }
    }
}
